# from django.http import JsonResponse
from drf_spectacular.utils import extend_schema
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.mixins import (CreateModelMixin,ListModelMixin,RetrieveModelMixin,UpdateModelMixin,)
from rest_framework.viewsets import GenericViewSet

from backend.cews.models import  PartVersion
from utils.autoschema import AutoDocSchema
from utils.decorators import request_data

from .serializers import AssetSerializer, PartVersionSerializer


from django_filters import rest_framework as filters
import django_filters

class CustomFilter(filters.FilterSet):
    # parts = filters.Filter(field_name='parts', lookup_expr='exact')
    class Meta:
        model = PartVersion
        fields = ['parts']
        

class PartVersionViewSet(
    GenericViewSet,
    RetrieveModelMixin,
    ListModelMixin,
    # UpdateModelMixin,
    # CreateModelMixin
):
    serializer_class = PartVersionSerializer
    queryset = PartVersion.objects.all()
    filterset_class = CustomFilter
    filter_backends = [django_filters.rest_framework.DjangoFilterBackend]
    